<?php
namespace app\common\model;

use think\Model;

class Info extends Model
{
//    protected $autoWriteTimestamp = true;
//    protected $type = [
//
//        'create_time'  =>  'timestamp:n-d',
//        'update_time'  =>  'timestamp:n-d',
//
//    ];
    
    protected $autoWriteTimestamp =true;
    protected $type = [
        'create_time'  =>  'timestamp:Y/m/d H:i:s',
        'update_time'  =>  'timestamp:Y/m/d H:i:s',
    ];
    
    public function getCreateTimeAttr($timestamp){
        
        return date('n-d',$timestamp);
        
    }
    
    public function cat(){
        return $this->hasOne('Category','id','catid')->field('id,thumb,title');
    }
    
    public function con(){
        return $this->hasOne('InfoData','info_id','id');
    }
    
    public function user(){
        return $this->hasOne('Member','id','user_id')->field('nickname,headimgurl,id');
    }
    
    public function agree(){
        return $this->hasOne('InfoAgree','info_id','id');
    }
    
    
    public function pic(){
        return $this->hasMany('InfoPic','info_id','id');
    }
    
    
    

}